home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / 4th86_v4.zip / INTRO.4TH < prev    next >
Text File  |  1994-01-02  |  21KB  |  535 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.    4th_86 version 4.01            INTRO.4TH                          page 1
  8.    
  9.    
  10.  
  11.           ( November 1993 - 4th_86 version 4.01 - MFB )
  12.  
  13.    Description of system
  14.    =====================
  15.  
  16.           In an attempt to keep this introduction short and easy to digest,
  17.    the description has been split into several files. It will help if you
  18.    print these to use as reference -- but this file along with the built
  19.    in HELP tutorial will get you started.
  20.  
  21.           Read also DISK.NDX for a description of all issued files and
  22.    their function.
  23.  
  24.    a) INTRO.4TH    this file
  25.    b) CELCIUS.WLK  a walkthrough of the procedure for writing a short
  26.                    program
  27.    b) WHY.UCC      a description of the objectives and philosophy of
  28.                    4th_86
  29.    c) GLOSSARY     a functional summary of most of the principal WORDS
  30.    d) MANUAL       a manual doubling as a tutorial
  31.    e) DISK.NDX     a last minute addition listing the files provided.
  32.  
  33.           The file TUTORIAL.TXT is not meant to be printed. It is loaded
  34.    into 4th_86 when the command HELP is issued and will then become a
  35.    hands-on interactive tutorial. It contains many control codes designed
  36.    to display parts of the system as the tutorial progresses and these may
  37.    confuse your printer if you attempt to print it.
  38.  
  39.           The files EXAMPLE1.4TH EXAMPLE2.4TH etc are required as part of
  40.    the interactive tutorial. They are standard ascii and can be printed if
  41.    you wish -- but there is little purpose in doing so.
  42.  
  43.    Configuration
  44.    =============
  45.           4th_86 will function either as a windowed or a full screen DOS
  46.    application within Windows 3.1. There is little advantage in doing this.
  47.    4th_86 is originally intended to run directly under DOS.
  48.  
  49.           The only configuration needed is to use your standard DOS editor
  50.    to edit the files EDITR.BAT and ASMBL.BAT.
  51.  
  52.           EDITR.BAT currently contains the statement \dos\edit %1.  EDIT is
  53.    the DOS 5.x editor and you should replace this with the name you type as
  54.    a command to execute your own favorite DOS editor. You can either
  55.    include a complete drive and path specification with it -- or you can
  56.    ensure that your PATH statement will allow DOS to find your editor.
  57.  
  58.           Note that if your DOS editor is a "memory hog" [ or you have too
  59.    many TSRs loaded ] the DEMONSTRATION 4th_86 may produce an "out of
  60.    memory" error due to it being an over-complete configuration.
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.    4th_86 version 4.01            INTRO.4TH                          page 2
  68.    
  69.    
  70.           You must also make sure that a copy of COMMAND.COM is in the ROOT
  71.    directory [ this is essential ] of the disk you are running 4th_86 from.
  72.    If you do not do this, 4th_86 will not be able to shell to DOS to
  73.    execute your editor. You should also add a line similar to SET COMSPEC
  74.    = C:\DOS\COMMAND.COM to your autoexec.bat file.
  75.  
  76.  
  77.           ASMBL.BAT currently contains command lines for Microsoft MASM,
  78.    LINK, and EXE2BIN. If you use the Microsoft MASM assembler -- no
  79.    configuration is needed to this file. If you use some other assembler-
  80.    linker combination; you will have to decide for yourself the equivalent
  81.    commands to put in ASMBL.BAT.
  82.  
  83.  
  84.           Both these batch files can be tested without using 4th_86. Simply
  85.    type ASMBL xxxx  where xxxx is the name of any [ COM format compatible ]
  86.    ASM file on your disk. The file should be assembled into a binary file
  87.    xxxx.BIN. Likewise to test EDITR simply type EDITR xxxx where xxxx is
  88.    any text file. Your editor should load the file xxxx and make it ready
  89.    for editing.
  90.  
  91.  
  92.           While 4th_86 can use EGA and CGA graphics -- graphics formats are
  93.    not needed to use 4th_86 in normal text mode.
  94.  
  95.    Video Page Swapping
  96.    ===================
  97.  
  98.           The issue version 4.01 of 4th_86 uses video page swapping, and it
  99.    is assumed you will be able to access video pages 0 1 and 2. The
  100.    demonstration version however has page swapping disabled to minimise the
  101.    chance of hardware incompatability problems.
  102.  
  103.  
  104.           The purpose of page swapping is to give any functions which shell
  105.    to DOS [ such as REDIT, SYS, BLOAD, INT3 ] their own display screens in
  106.    order that the previous 4th_86 video display can be left undisturbed and
  107.    returned to. When page swapping is implemented, 4th_86 will work on page
  108.    1 whilst DOS-shell functions will work in page 0. Things were arranged
  109.    this way as some DOS editors may not be capable of working other than in
  110.    page 0.
  111.  
  112.  
  113.           When you understand the system a bit more you can set it up for
  114.    page swapping or constant page0. This is controlled by a variable
  115.    IVPAGE. IVPAGE in the demonstration version is set to 0.  To implement
  116.    page swapping set IVPAGE to 1 on the command line when you initiate
  117.    4TH86DEM. In other words, from the DOS prompt type
  118.  
  119.           4TH86DEM 1 IVPAGE ! < return >
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.    4th_86 version 4.01            INTRO.4TH                          page 3
  127.    
  128.    
  129.    Help Tutorial
  130.    =============
  131.  
  132.           The HELP tutorial is contained in a file called TUTORIAL.TXT. In
  133.    the demonstration version of 4th_86 the tutorial [ windowed ] mode is
  134.    entered automatically on startup. If you want to disable this -- either
  135.    delete or rename TUTORIAL.TXT. If 4th_86 can't find TUTORIAL.TXT to load
  136.    it will give an error message and bypass the color and windowing code.
  137.  
  138.           Of course -- this will also render the HELP command ineffective.
  139.  
  140.    Format of Source files
  141.    ======================
  142.  
  143.           All ASM and 4TH source is standard ascii and can be edited with
  144.    any text editor. Because an extended ascii character 179 is used in some
  145.    of the 4TH source code to line up if -- then -- else etc; it is
  146.    desirable that the editor you use should display ascii 179 as the
  147.    correct asciii-graphics character -- a vertical bar.
  148.  
  149.    Making use of EDITR.BAT
  150.    =======================
  151.  
  152.           One of the major features of 4th_86 is the ability to
  153.    **automatically**  "shell" from 4th_86 in to your favorite DOS editor.
  154.    More than this however -- if the file you are editing is 4th source code
  155.    -- you can have it loaded automatically each time you exit your editor
  156.    and return to 4th_86. The magic word is REDIT -- but first you have to
  157.    define the name of the file xxxx that you wish to use.
  158.  
  159.           To do this you type USING xxxx. You need do this only once --
  160.    the name will remain in effect until you redefine it with USING.
  161.  
  162.           Let's say you were not happy with the file EXAMPLE1.4th and you
  163.    wanted to do some work on it. You wish to edit it; then load it into
  164.    4th_86 to test it; then edit it a second time to correct it further ;
  165.    then reload it into 4th_86 again -- and so on repetitively until you
  166.    are satisfied.
  167.  
  168.           First enter the command USING EXAMPLE1.4TH. Then type REDIT. If
  169.    you have configured EDITR.BAT properly you should now be shelled out to
  170.    your editor looking at EXAMPLE1.4TH -- and no longer in 4th_86.
  171.  
  172.           Do not change anything for the moment -- simply exit from your
  173.    editor. The updated EXAMPLE1.4TH will be saved to disk -- you will find
  174.    yourself back in 4th_86 -- and you will see the file EXAMPLE1.4TH being
  175.    loaded.
  176.  
  177.           Repeat the process by again typing REDIT  [ no need to type
  178.    USING etc ]. Again -- as you exit your editor and re-enter 4th_86; the
  179.    file EXAMPLE1.4TH will be loaded ** a second time **.
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.    4th_86 version 4.01            INTRO.4TH                          page 4
  187.    
  188.    
  189.           This is not really what you want -- multiple definitions of the
  190.    same words. In fact -- unless you have included in the file the
  191.    statement ON REDEFINE -- 4th_86 will halt and ask you if you really
  192.    want to redefine the words. If you include ON  REDEFINE the words will
  193.    be redefined without any warning query.
  194.  
  195.    Using FORGET when REDITing
  196.    ==========================
  197.  
  198.           There is a technique whereby you can REDIT multiple times without
  199.    redefining words. You start every 4th source file with the statements
  200.  
  201.           FORGET STRT
  202.           : STRT ;
  203.           OFF REDEFINE
  204.  
  205.           And in addition -- immediately before you type USING EXAMPLE1.4TH
  206.    [ or whatever source file you name ]  you must also type : STRT ;
  207.  
  208.           What is happening is that you put a "bookmark" arbitarily named
  209.    STRT into 4th_86 before you do any editing. You do this by defining a
  210.    "null" word [ ie it contains no code -- and does nothing ] called STRT.
  211.    Note that the actual word STRT has no significance. Any word can be
  212.    used so long as it doesn't clash with an existing word in 4th_86.
  213.  
  214.           As with USING you only need do this once. Now every time you
  215.    exit your editor -- and EXAMPLE1.4TH starts to load -- the first thing
  216.    it does is to FORGET the "bookmark" -- ** and all the words following
  217.    it **. It effectively clears out all the results of the previous load.
  218.  
  219.           It then redefines the bookmark STRT -- and proceeds to load the
  220.    EXAMPLE1.4TH definitions in to a cleaned out load area.
  221.  
  222.    Using PRINTLOAD
  223.    ===============
  224.  
  225.           If you find that a 4th source file encounters a load problem
  226.    half way through -- you will want to see it displayed on screen as it
  227.    loads, in order that you can detect the point at which it fails.
  228.  
  229.           To do this, add ON PRINTLOAD to the above three statements. If
  230.    you don't want the text displayed -- include OFF PRINTLOAD.
  231.  
  232.    Using EDIT and RELOAD
  233.    =====================
  234.  
  235.           The word REDIT in fact executes EDIT and then RELOAD in
  236.    sequence. They can be used independently if you wish. EDIT will shell
  237.    to your editor; but will not do any load when you exit the editor.
  238.    Similarly RELOAD will not shell to your editor but will load the file
  239.    that has previously been defined by USING.
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.    4th_86 version 4.01            INTRO.4TH                          page 5
  247.    
  248.    
  249.           You would use EDIT rather than REDIT if you wanted to edit a
  250.    non-4th-source file -- such as TUTORIAL.TXT -- or an ASM file which had
  251.    to be BLOADed [ Binary loaded ] .
  252.  
  253.  
  254.    Using FLOAD
  255.    ===========
  256.  
  257.           To load a 4th source file [ say TEST.4TH ] into 4th_86 you can
  258.    either type  FLOAD TEST.4TH -- or you can type " TEST.4TH" LOAD.
  259.  
  260.           Note that there is no requirement that 4th source files carry
  261.    the suffix 4TH. They can have any suffix -- or none -- so long as the
  262.    code is valid 4th code.
  263.  
  264.    Using BLOAD
  265.    ============
  266.  
  267.           It is recommended that you skip over this paragraph if you are a
  268.    beginner. It will be a long time before you have cause to use BLOAD --
  269.    if ever. It is however a feature of 4th_86 and is described here for
  270.    anyone who is interested.
  271.  
  272.                  BLOAD is an "intelligent" command rather like REDIT. It is
  273.    used to load MASM source code into 4th_86 -- by automatically shelling
  274.    to DOS and calling MASM; LINK; EXE2BIN to create a xxx.BIN file; which
  275.    it then loads.
  276.  
  277.           It is further "intelligent" in that it first compares the date
  278.    and time of any existing BIN file with the corresponding ASM file. Only
  279.    if the ASM file is of a later date than the BIN file is the assemble
  280.    etc carried out. Otherwise the existing BIN file will be loaded as-is.
  281.    To "force" an assembly -- simply delete any existing BIN file.
  282.  
  283.           A pointer called HEAD is maintained in all Forths which points
  284.    to the address at which all new code [ whether FLOADed or BLOADed ] is
  285.    to be placed. To ensure that MASM assembles the ASM file at the
  286.    corresponding ORG value -- the first thing BLOAD does as it shells to
  287.    MASM is to write a two line file called ORGFILE to disk.
  288.  
  289.           The user need not worry about ORGFILE -- it is written and used
  290.    automatically. All ASM files contain the statement INCLUDE ORGFILE and
  291.    this re-sets the ORG equ 100H statement to ORG equ ( HEAD @ )
  292.  
  293.           A file called TEST.ASM is provided to demonstrate the structure
  294.    needed -- and to allow you to try out the BLOAD command. After you have
  295.    BLOADed it -- use DDICT to verify the words -- and use DD to disassemble
  296.    them. Verify that the words execute and print the intended messages.
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.    4th_86 version 4.01            INTRO.4TH                          page 6
  304.    
  305.    
  306.    BLOAD and In-Line assembly
  307.    ==========================
  308.  
  309.           Version 4.01 has full in line 8086 assembly -- and a
  310.    disassembler. Whereas 4th definitions are started with a colon --
  311.    assembly routines are started with the word CODE
  312.  
  313.  
  314.           CODE TEST       pop     ax
  315.                           cmp     ax,23h
  316.                           jz      found
  317.                           blah blah blah
  318.                           jmp     done
  319.           | found         yak yak yak
  320.           | done          more yak blah
  321.               labels
  322.           ;
  323.  
  324.    or    CODE TEST        pop     ax
  325.                           cmp     ax,23h
  326.           ifz
  327.                           yak yak yak
  328.           else
  329.                           blah blah blah
  330.           then
  331.                           more yak blah
  332.           ;
  333.  
  334.           Look at some of the 4th source code on disk -- and also the
  335.    files MASMTST and MASM.TST for illustrations.
  336.  
  337.           The point being made here is that you may never need to use
  338.    BLOAD. Unless you are writing a complicated assembly module to BLOAD,
  339.    Inline assembly will be much easier.
  340.  
  341.  
  342.    Logical operators AND, OR, XOR
  343.    ==============================
  344.  
  345.  
  346.           4th_86 allows code to be entered in either FORTH words -- or in
  347.    ASSEMBLY language. Normally there is no duplication as 4th_86 words have
  348.    been chosen not to conflict with comparable assembly mnemonics. For
  349.    example -- SHR is an assembly word. SHR8 and ->L are comparable 4th_86
  350.    words.
  351.  
  352.  
  353.           In the case of AND, OR and XOR the same words are used for both
  354.    assembly useage and 4th_86 useage. 4th_86 resolves the confusion by
  355.    testing a variable called CODEFLAG which is "set" when ASSEMBLY mode is
  356.    in operation -- and not set in FORTH mode.
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.    4th_86 version 4.01            INTRO.4TH                          page 7
  364.    
  365.    
  366.            : and codeflag @ if /and else and then ;
  367.            : or  codeflag @ if /or  else or then ;
  368.            : xor codeflag @ if /xor else xor then ;
  369.  
  370.           This functions without any problems -- but there may be
  371.    situations where you wish to over-ride the CODEFLAG decision and
  372.    determine specifically which mode to use.
  373.  
  374.           If you specifically want to use the assembly mnemonic then use
  375.    /AND. If you specifically want to use the 4th_86 word use -AND.
  376.  
  377.  
  378.    Turnkey Demonstration Files
  379.    ===========================
  380.  
  381.           Several demonstration files are included. FP_DEMO.COM shows the
  382.    use of floating point; while HILBERT.COM, MAND.COM etc show the use of
  383.    EGA graphics. See the file DISK.NDX for a description -- or just run
  384.    them and watch what happens.
  385.  
  386.           The source code for several of these demos is included along with
  387.    the necessary image files APPS.IMG and APPSFP.IMG to create standalone
  388.    demos. To create HILBERT.COM for example -- simply fire up 4TH_86FP.COM
  389.    and then type FLOAD HILCOM.DEM.
  390.  
  391.           By examining the demonstration source files [ xxx.DEM and
  392.    xxx.4TH] you can see how to create your own turnkey programs.
  393.  
  394.    DOS Command Line parameters
  395.    ===========================
  396.  
  397.           4th_86 allows words to be included on the command line. For
  398.    example you could create HILBERT.COM from the DOS prompt by typing at
  399.    the DOS prompt   4TH86FP  FLOAD  HILCOM.DEM  < return >.
  400.  
  401.           This can be extremely useful as the above can be included in a
  402.    DOS batch file as all DEM files end by returning to DOS naturally.
  403.  
  404.           File BUILDEM.BAT
  405.           ----------------
  406.           4th_86FP fload smith.dem
  407.           4th_86FP fload square.dem
  408.           4th_86FP fload hilcom.dem
  409.           4th_86FP fload fpoint.dem
  410.           4th_86FP fload 4demo.dem
  411.           4th_86FP fload mand.dem
  412.  
  413.     ( ** NOTE ** because of the 10 second delay built into the exit to DOS
  414.     for the DEMO file the above is only a fast option with the full non-
  415.     demo version. It will however work. )
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.    4th_86 version 4.01            INTRO.4TH                          page 8
  423.    
  424.    
  425.           You could also type something like
  426.  
  427.         4TH86FP  1 IVPAGE !  UNSPLIT  USING  EXAMPLE1.4TH  EDIT < return >
  428.  
  429.           Though there is little to be gained by doing so as opposed to
  430.    entering the  secondary commands one at a time at the 4th_86 prompt.
  431.  
  432.    Use of INT3
  433.    ===========
  434.  
  435.           If 4th_86 is started from within some debugger utility [ for
  436.    example by typing DEBUG 4TH_86FP.COM < return > and then typing G at the
  437.    Debug prompt ] you will at any time be able to use the Forth word INT3
  438.    to activate the debugger.
  439.  
  440.           This should hardly be necessary as 4th_86 has its own very
  441.    effective debugging words -- but it can be useful to examine memory etc.
  442.  
  443.           To return from the DOS debugger, start execution at address 200H.
  444.    The usual command is G=200
  445.  
  446.    Hard copy  from screen
  447.    ======================
  448.  
  449.           The normal DOS command  shift-PrtScr will dump the existing
  450.    screen to printer.
  451.  
  452.           The normal dos ctl-P will toggle on and off continuous echo of
  453.    screen output to printer.
  454.  
  455.           If ctl-P is activated to printer; ascii text disk files can be
  456.    printed while in 4th_86 by using the 4th_86 word TYPE. The word COPY is
  457.    not implemented in 4th_86 -- nor is the "filename"  PRN.
  458.  
  459.    Extensability
  460.    =============
  461.  
  462.           Remember that one principle of FORTH is that the system can be
  463.    "extended" by simply defining new words that you need -- and then
  464.    FSAVEing or SAVESYSing the resulting file.
  465.  
  466.           If you felt that you needed some new words such as COPY or RENAME
  467.    or DELETE -- or indeed complicated windowing techniques -- you can add
  468.    them at any time.
  469.  
  470.           The word SYNONYM will allow you to rename words if you wish to
  471.    adhere to some alternatives that you regard as more conventional or
  472.    "standard". Alternatively you can simply issue another defenition --
  473.  
  474.           : NEW_WORD   OLD_WORD  ;
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.    4th_86 version 4.01            INTRO.4TH                          page 9
  482.    
  483.    
  484.           If you don't *like* the way an existing definition works -- you
  485.    can redefine that defenition without affecting the way all existing
  486.    words which use [ and continue to use ] the original definition
  487.    function.
  488.  
  489.           You *can* also redefine in a retrospective way so that existing
  490.    words now use your new definition instead of the one they were designed
  491.    to interface with. This is inadvisable -- as without the complete
  492.    source code you will not know the global effects of your changes on
  493.    existing code.
  494.  
  495.           Not all words can be disassembled using DD -- because they have
  496.    been OMITted from the dictionary either as embodying "restricted" code
  497.    -- or because they have no purpose other than as intermediate words
  498.    used in building up other more meaningful words. The disassembler for
  499.    example contains dozens of words KIND01  KIND02  KIND03 etc -- which
  500.    have no use individually in any application and are therefore OMITted
  501.    from the dictionary to conserve space.
  502.  
  503.           A disassembly which can not find a word will print OOPS in place
  504.    of it's name.
  505.  
  506.    Further Tutorials
  507.    =================
  508.  
  509.           If I get evidence that reasonable interest is being shown in the
  510.    BBS version of 4th_86, I will prepare more organised and detailed
  511.    TUTORIAL.TXT files and EXAMPLEnn.4TH files to go with them. For the
  512.    moment use what HELP is exists -- look at the provided source code --
  513.    and read the additional examples in MANUAL. Above all -- practice as a
  514.    hands-on interactive exercise.
  515.  
  516.    Further Versions
  517.    ================
  518.  
  519.           While version 4.01 provides several separate 64K segments for
  520.    dictionary; cross compile; etc -- it still restricts the code segment to
  521.    64K maximum. The next version [ which is now functional ] extends the
  522.    code segment to 128K with the possibility of even further extensions.
  523.  
  524.           Work is still in progress to adapt this extended addressing into
  525.    a restructured overall philosophy.  Version 4.01 is essentially intended
  526.    as a learning environment -- and the present 64K limit on code segment
  527.    does not really impose any severe limitations. Extending this 64K for
  528.    its own sake -- and incurring EXE file structures in isolation of a
  529.    total re-design of  any clearly defined objective would serve little
  530.    purpose.
  531.  
  532.           It is hoped that users of version 4.01 will provide feedback of
  533.    their impressions. Read WHY.UCC for a further discussion of system
  534.    philosophy.
  535.